package display;

import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import classes.QRCode;
import classes.QRImage;

/**
 * SimpleTestGUI
 * 
 * @author Nicole Nelson
 */
public class SimpleTestGUI 
{
	JFrame display;
	JPanel picture;
	
	/*
	 * Creates the Display and sets the title to the string
	 */
	public SimpleTestGUI(String title)
	{
		display = new JFrame();
		display.setTitle(title);
		display.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		picture = new JPanel();
	}
	
	/*
	 * Displays the original image, the Qr Code, and the result of the qr code
	 */
	public void setImage(QRImage qrimg, QRCode qrcode)
	{		
		display.setSize(qrimg.getOriginalImage().getWidth() * 2 + 60, qrimg.getOriginalImage().getHeight() + 60);

		picture.add(new JLabel(qrcode.getURL()));
		picture.add(new JLabel(new ImageIcon(qrimg.getOriginalImage())));
		picture.add(new JLabel(new ImageIcon(qrcode.getCode())));
		display.add(new JScrollPane(picture));	
	}

	public void setImage(BufferedImage image)
	{
		picture.add(new JLabel(new ImageIcon(image)));
		display.add(new JScrollPane(picture));
	}
	
	/*
	 * displays the gui to the screen
	 */
	public void displayGUI()
	{
		display.setVisible(true);
	}	
}
